#ifndef GRAPHICSVIEW_H
#define GRAPHICSVIEW_H

#include <QGraphicsView>
#include <QFile>
#include "svgnode.h"

#include "appmanager.h"

class GraphicsScene;
class MenuManager;

class QMenu;
class ActionManager;

class GraphicsView : public QGraphicsView
{
    Q_OBJECT
public:
    enum GraphicsSceneContextMenuType
    {
      NoContextMenu,
      SceneContextMenu,
      ItemContextMenu,
      ItemGroupContextMenu
    };
	enum WheelZoomType
	{
		WheelZoomScene,
		WheelZoomComponet
	};
    static void setGraphicsSceneContextMenuType(GraphicsSceneContextMenuType type = SceneContextMenu);
    static GraphicsSceneContextMenuType getGraphicsSceneContextMenuType();

	void setKeyControlWheelEnable(bool b)
	{
		mKeyControlWheelEnable = b;
	}
	void setWheelZoomType(WheelZoomType type)
	{
		mZoomType = type;
	}
    GraphicsView(QWidget *parent=0);
    ~GraphicsView();
    // get scene
    GraphicsScene* getScene();
    // open svg file
    void openFile(QFile *file);
    void setViewSize(QSize);
    void setActionManager(ActionManager *mana);
    void setMenuManager(MenuManager *mana);
public slots:
    void slotSetSceneScale(QString);
protected:
    void contextMenuEvent(QContextMenuEvent *event);
    void dragMoveEvent(QDragMoveEvent *event);
    void dragEnterEvent(QDragEnterEvent *event);
    void dropEvent(QDropEvent *event);
    void mouseMoveEvent ( QMouseEvent*e) ;
    void mousePressEvent(QMouseEvent*e);
    void mouseReleaseEvent(QMouseEvent*e);
    void keyPressEvent(QKeyEvent *event);
    void keyReleaseEvent(QKeyEvent *event);
    void wheelEvent(QWheelEvent* event);
signals:
    void sigMousePos(QPointF pos);
private:
    GraphicsScene *mScene;
    static GraphicsSceneContextMenuType s_ContextMenuType;
    ActionManager* m_ActionManager;
    MenuManager* m_MenuManager;

	bool mKeyControlWheelEnable;
	bool mKeyControlPress;
	WheelZoomType mZoomType;
};

#endif // GRAPHICSVIEW_H
